// 模块封装————提示信息

let m = getPageInfo(),
    tips = document.getElementsByClassName('tips')[0],
    inner = document.createElement('div'),
    t_p = document.createElement('p'),
    t_cont = document.createElement('div'),
    t_p2 = document.createElement('p'),
    t_btn = document.createElement('div'),
    small_tip = document.createElement('div'),
    t_btn2 = document.createElement('div')
// 将tips占满全屏
tips.style.width = `${m.width}px`
tips.style.height = `${m.height}px`
tips.style.display = 'block'

// t_p 为提示信息标题
t_p.innerHTML = 'WebMOOC餐厅开业啦'
t_cont.innerHTML = 'WebMOOC餐厅即将开业，请认真经营你的餐厅吧，餐厅经营需要做好下面几件事，加油!'
t_p2.innerHTML = '招聘厨师 迎接客人 准备美食'
t_btn.innerHTML = '开始经营'
inner.className = 'inner'
t_btn.className = 'btn'
t_cont.className = 'cont'
inner.appendChild(t_p)
inner.appendChild(t_cont)
inner.appendChild(t_p2)
inner.appendChild(t_btn)
tips.appendChild(inner)
t_btn.style.marginLeft = '130px'

t_btn.onclick = function () {
    // 开始经营后关闭界面之后进行游戏介绍操作
    tips.style.display = 'none'
    // 出现第一个顾客
    Custom()
    small_tip.style.display = 'block'
    small_tip.innerHTML = '餐厅目前有空位，赶快点击座位让客人入座就餐吧!'
    setTimeout(() => {
        // 小提示出现2秒后自动消失
        small_tip.style.display = 'none'
    }, 2000)
    // 开始计时 240秒为一天 7天一周
    Day_day()

}

// 常用提示
// 将small_tips设置宽高
small_tip.className = 'small_tip'
small_tip.style.width = `${m.width * 0.6}px`
small_tip.style.height = `${m.height / 13}px`


let body = document.getElementsByTagName('body')[0]
body.appendChild(small_tip)

function S_Tips(info) {
    small_tip.style.display = 'block'
    small_tip.innerHTML = info
    setTimeout(() => {
        // 小提示出现2秒后自动消失
        small_tip.style.display = 'none'
    }, 2000)
}

function Tips(title, maincontent, seccontent, btnhtml1, btnhtml2) {
    // 封装大提示信息组件
    if (t_btn2.className !== '') {
        t_p.innerHTML = title
        t_cont.innerHTML = maincontent
        t_p2.innerHTML = seccontent
        t_btn.innerHTML = btnhtml1
        t_btn2.innerHTML = btnhtml2
        tips.style.display = 'block'
        t_btn.onclick = function () {
            // 确认雇佣 
            if (parseInt(document.getElementsByClassName('money')[0].children[0].innerHTML) >= 100) {
                // 判断余额是否足够
                document.getElementsByClassName('money')[0].children[0].innerHTML = parseInt(document.getElementsByClassName('money')[0].children[0].innerHTML) - 50
                addcooker()
                tips.style.display = 'none'
            } else {
                S_Tips('余额不足哦~')
                tips.style.display = 'none'
            }

        }
        t_btn2.onclick = function () {
            // 不雇佣       
            tips.style.display = 'none'
        }
    } else {
        t_btn2.className = 'btn'
        t_btn.style.marginLeft = '60px'
        t_btn2.style.marginLeft = '40px'
        inner.appendChild(t_btn2)
        // 封装提示信息组件
        t_p.innerHTML = title
        t_cont.innerHTML = maincontent
        t_p2.innerHTML = seccontent
        t_btn.innerHTML = btnhtml1
        t_btn2.innerHTML = btnhtml2
        tips.style.display = 'block'
        t_btn.onclick = function () {
            // 确认雇佣 
            console.log(parseInt(document.getElementsByClassName('money')[0].children[0]))
            if (parseInt(document.getElementsByClassName('money')[0].children[0].innerHTML) >= 100) {
                // 判断余额是否足够
                document.getElementsByClassName('money')[0].children[0].innerHTML = parseInt(document.getElementsByClassName('money')[0].children[0].innerHTML) - 50
                addcooker()
                tips.style.display = 'none'
            } else {
                S_Tips('余额不足哦~')
                tips.style.display = 'none'
            }

        }
        t_btn2.onclick = function () {
            // 不雇佣       
            tips.style.display = 'none'
        }
    }

}